﻿<%@ Page Title="Kullanıcı Girişi | TodayWho" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="TodayWho.login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="https://connect.facebook.net/tr_TR/all.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
            $(document).ready(function () {
                //FB.init({ appId: '283575318389020', status: true, cookie: true, xfbml: true });
                FB.init({ appId: '274521685956429', status: true, cookie: true, xfbml: true });
                $("#imgFbLogin").click(function () {
                    baglan();
                });

            });
            

            function baglan(RedirectUrl) {
                FB.getLoginStatus(function (response) {
                    if (response.status == "connected") {
                        //location = '/Login?callback=1&uid=' + FB.getUserID() + '&token=' + FB.getAccessToken() + '';
                        //alert(FB.getUserID());
                        loginAsync();
                    }
                    else {
                        FB.login(function (response1) {
                            alert(response1.status);
                            if (response1.status == "connected") {
                                alert(FB.getUserID());
                                loginAsync();
                                //location = '/Login?callback=1&uid=' + FB.getUserID() + '&token=' + FB.getAccessToken() + '';
                            } else {
                                alert("Uygulamayı kullanmak için izin vermelisiniz");
                            }
                        }, { scope: 'email' });
                    }
                });
            }

            function loginAsync() {
                FB.api('/me', function (response) {
                    //alert(response.name+' '+response.email);
                    $.ajax({
                        type: "POST",
                        url: "login.aspx/FbLogin",
                        data: "{'fbUserId':'" + FB.getUserID() + "','token':'" + FB.getAccessToken() + "','email':'" + response.email + "','name':'" + response.name + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (msg) {
                            window.location = msg.d;
                        }
                    });
                });
            }
         </script>
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Panel ID="pnl" runat="server" DefaultButton="btnLogin">
    <div id="stylized" class="myform">
        
            <h1>Kullanıcı Girişi</h1>
            <p></p>

            <div style="margin-bottom:30px;height:70px">
                <label>Email
                <span class="small">Email adresinizi giriniz.</span>
                </label>
                <asp:TextBox ID="txtEmail" runat="server" CssClass="text"></asp:TextBox>
                
                <asp:RequiredFieldValidator ID="rqTxtEmail" runat="server" ControlToValidate="txtEmail" Display="Dynamic" ValidationGroup="vgLogin" ErrorMessage="Lütfen email adresini giriniz." >*</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="regMail" runat="server" ControlToValidate="txtEmail" ErrorMessage="Lütfen geçerli bir email adresi giriniz." ValidationGroup="vgLogin"
			    ValidationExpression="^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$" >*</asp:RegularExpressionValidator>
            </div>
            
           
            
            <div class="spacer"></div>

             <div style="margin-bottom:30px;height:70px">
                <label>Sifre
                <span class="small">Şifrenizi giriniz.</span>
                </label>
                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" CssClass="text"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rqTxtPassword" runat="server" ControlToValidate="txtPassword" Display="Dynamic" ValidationGroup="vgLogin" ErrorMessage="Lütfen şifrenizi giriniz.">*</asp:RequiredFieldValidator>
                 <asp:Button ID="btnLogin" runat="server" CssClass="button" Text="Giriş" OnClick="btnLogin_OnClick" ValidationGroup="vgLogin" />
                 <a href="forgotpassword.aspx" style="font-size:12px;line-height:1em;color:Gray;text-decoration:underline;margin-left:30px" >şifremi unuttum...</a>
            </div>

     <div id="fb-root"></div>

     
     <div><img id="imgFbLogin" src="style/images/facebook-ile-baglan.png" alt='facebook_baglan' style="cursor:pointer" /></div>
        
     




            <div class="spacer"></div>

 

            <p style="border-bottom:none"><asp:Label ID="lblLoginErrors" runat="server" Visible="false" ForeColor="Red"></asp:Label></p>
            <asp:ValidationSummary ID="vsumLogin" runat="server" ValidationGroup="vgLogin" DisplayMode="BulletList" ShowSummary="true" />
            <div class="spacer"></div>

        </div>
      </asp:Panel>

</asp:Content>
